<%
    String number1 = request.getParameter("number");
    int number2 = Integer.parseInt(number1);
    int sum = 0;
    for (int i = 1;i<=number2;i++){

        sum=sum+i;
    }
    out.write(String.valueOf(sum));
%>

<%--
  Created by IntelliJ IDEA.
  User: JAVA
  Date: 2018/5/2
  Time: 13:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="textml;charset=UTF-8" language="java" %>
<html>
    <head>
        <title>Title</title>
    </head>
    <body>
        <body>
            <%
                Integer count = (Integer)session.getAttribute("count");
                if(count==null){
                    count=1;
                    session.setAttribute("count",count);
                }else{
                    count++;
                    session.setAttribute("count",count);
                }
            %>
            访问次数为：<%=count %>

        </p>
    </body>

</body>
    <html>
